/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx.controller;

import cn.webrx.mapper.DbMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootVersion;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p></p>
 * <p>Powered by webrx On 2023-04-19 11:42:25</p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
@RestController
public class IndexController {
    @Autowired
    DbMapper dm;

    //http://localhost:8080/
    @GetMapping
    public String home(){
        return dm.ver();
    }

    //http://localhost:8080/dbs
    @GetMapping("/dbs")
    public List<String> dbs(){
        return dm.dbs();
    }


    //http://localhost:8080/tbs?name=mysql
    //http://localhost:8080/tbs
    @GetMapping("/tbs")
    public List<String> tbs(@RequestParam(value = "name", defaultValue = "db") String name){
        return dm.tbs(name);
    }



    //http://localhost:8080/tbs?name=mysql/version
    @GetMapping("/version")
    public String index(){
        return SpringBootVersion.getVersion();
    }
}


